﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SqlCeManager.Setup
{
    public partial class FormPolaczenia : ProgNetComponentsDx.Forms.BaseSqlCeGridForm
    {
        public event EventHandler ConnectionsChanged;
        public FormPolaczenia()
        {
            InitializeComponent();
        }
        protected override bool Save()
        {
            bool res = base.Save();
            if (res)
            {
                if (ConnectionsChanged != null)
                    ConnectionsChanged(this, EventArgs.Empty);
            }
            return res;
        }

        private void gvMain_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete && modeProvider1.CurrentMode == ProgNetComponentsDx.Enums.FormMode.Edit)
            {
                DataRow r = gvMain.GetFocusedDataRow();
                if (r != null)
                {
                    if ((this.MdiParent as FormMain).ConnectionOpened(r["STP_POL_ID"].AsInt()))
                    {
                        this.ShowDxWarningDialog("Nie można usunąć otwartego połączenia");
                    }
                    else
                    {
                        r.Delete();
                    }
                }
            }
        }
    }
}
